package news;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.sax.StartElementListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class List_ls implements OnItemClickListener{

	public List<Rss_item> lr=new ArrayList<Rss_item>();
	public Activity act;
	public Rss_item ri;
	
	public List_ls(List<Rss_item> lr1,Activity act1){
		this.lr=lr1;
		this.act=act1;
	}
	
	public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {
		// TODO Auto-generated method stub
		ri=lr.get(pos);
		showdl(ri, act);
	}
	
	public void showdl(Rss_item rss,Context ct){
		try{
			final Uri myLink =  Uri.parse(rss.getLink());
			AlertDialog.Builder adb=new AlertDialog.Builder(ct);
			adb.setTitle("hello");
			adb.setMessage( rss.getTitle() + "\n\n" 			    		    
	    		 	+ rss.getDes() + "\n" );
			adb.setPositiveButton("close", null);
			adb.setNegativeButton("More", new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface arg0, int arg1) {
					// TODO Auto-generated method stub
					Intent i=new Intent(Intent.ACTION_VIEW,myLink);
					act.startActivity(i);
				}
			});
			adb.show();
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}

}
